package com.guangyunl.arithmetic;

public class Demo02Arithmetic {
    public static void main(String[] args) {
        System.out.println("=====================");
        System.out.println("++ 和 -- 单独使用");
        System.out.println("=====================");

        int i = 10;
        int j = 10;
        j++;
        ++i;
        System.out.println("j = " + j); // j = 11
        System.out.println("i = " + i); // i = 11
        System.out.println("=====================");
        System.out.println("++ 和 -- 混合使用");
        System.out.println("=====================");

        int n1 = 100;
        System.out.println("n1初始值 = " + n1);
        System.out.println("int result01 = ++n1;");
        int result01 = ++n1;
        System.out.println("result01 = " + result01); // result01 = 101
        System.out.println("n1 = " + n1); // n1 = 101
        System.out.println("=====================");

        int n2 = 100;
        System.out.println("n2初始值 = " + n2);
        System.out.println("int result02 = n2++;");
        int result02 = n2++;
        System.out.println("result02 = " + result02); // result02 = 100
        System.out.println("n2 = " + n2); // n2 = 101
        System.out.println("=====================");

        int x = 10;
        int y = 20;
        int result03 = x++ + --y + ++x;
        //              10 +  19 + 12 = 41
        System.out.println("result03 = " + result03); // result03 = 41
        System.out.println("=====================");

        // 面试真题
        int c = 10;
        c = c++;
        System.out.println("c = " + c); // c = 10
        System.out.println("=====================");
    }
}
